﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;

public partial class resumedownload : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Request.Params["user"] != null)
        {
            bool filevalid = false;
           
            string filepath = Server.MapPath("app_data/resume/" + Request.Params["user"] + ".doc");
            System.IO.FileInfo file = new System.IO.FileInfo(filepath);

            if (file.Exists)
            {
                filevalid = true;
            }
            else
            {
                filepath = Server.MapPath("app_data/resume/" + Request.Params["user"] + ".docx");
                file = new System.IO.FileInfo(filepath);
                if (file.Exists)
                {
                    filevalid = true;
                }

            }
            if (filevalid)
            {

                Response.Clear();

                Response.AddHeader("Content-Disposition", "attachment; filename=" + file.Name);

                Response.AddHeader("Content-Length", file.Length.ToString());

                Response.ContentType = "application/octet-stream";

                Response.WriteFile(file.FullName);

                Response.End();

            }

            else
            {

                Response.Write("This file does not exist.");

            }


        }
    }
}
